package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.CheckGroupService;
import com.itheima.health.service.CheckItemService;
import com.itheima.health.service.MemberService;
import com.itheima.health.service.SetMealService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ：石破天
 * @date ：Created in 2022年06月07日
 * @description ：
 * @version: 1.0
 */
@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
@Api(tags = "手机端套餐接口")
public class MobileSetMealController {
    @Autowired
    private MemberService memberService;

//    //任务七：查询所有套餐
//    @GetMapping("/getSetmeal")
//    public Result getSetmeal() {
//        log.info("[查询所有可预约套餐]");
//        List<Setmeal> allSetmeal = memberService.findAllSetmeal();
//        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS, allSetmeal);
//    }
//
//    //任务九：套餐详细信息
//    @GetMapping("/findById")
//    public Result findSetmealById(Integer id) {
//        log.info("[查询套餐的详情信息]");
//        Setmeal setmealById = memberService.findSetmealById(id);
//        if (setmealById == null) {
//            return new Result(false, MessageConst.QUERY_SETMEAL_FAIL);
//        }
//        return new Result(true, MessageConst.QUERY_SETMEAL_FAIL, setmealById);
//    }

    @Autowired
    private SetMealService setMealService;

    /* 获取套餐 */
    @GetMapping("/getSetmeal")
    public Result getSetmeal() {
        List<Setmeal> setmeals = setMealService.getSetmealList();
        if (setmeals != null) {
            return new Result(true, MessageConst.GET_SETMEAL_LIST_SUCCESS, setmeals);
        }
        return new Result(false, MessageConst.GET_SETMEAL_LIST_FAIL);
    }

    /* 根据套餐Id查询套餐信息 */
    @GetMapping("/findById")
    public Result findById(@RequestParam Integer id) {
        Setmeal setmeal = setMealService.findById(id);
        if (setmeal != null) {
            return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS, setmeal);
        }
        return new Result(false, MessageConst.QUERY_SETMEAL_FAIL);
    }
}
